#include "study_send.h"

#include <iostream>
#include <algorithm>


study_send::study_send()
{
}

study_send::~study_send()
{
}

bool study_send::start()
{

    for(ntype::signalid_t icount = 0; icount < signal_count_max; icount ++)
    {
      psignal_study_forward->setstudysignalid(icount);
      psignal_study_forward->send(null, 0);
//      psignal_study_back->setstudysignalid(icount);
//      psignal_study_back->send(null, 0);

//      printNeuroNet(icount);
    }
    printNeuroNet(0);
    printNeuroNet(1);
    printNeuroNet(2);
    printNeuroNet(3);

    psignal_study_back->send(null, 0);

  return true;

}

ntype::error_t study_send::getNeuroNetError()
{
  int sig_id_max = study_expeced_signal.size();
  ntype::error_t err = 0.0;
  ntype::error_t err_tmp = 0.0;
    for(int sig_id = 0; sig_id < sig_id_max; sig_id ++)
    {
        psignal_study_forward->setstudysignalid(sig_id);
       err_tmp = psignal_study_forward->geterror(study_expeced_signal[sig_id]);
//       std::cout << "err.val: " << err_tmp << std::endl;
       err += err_tmp;
    }
//    std::cout << "sig.id.max.val: " << sig_id_max << std::endl;
    err = err / (ntype::error_t )(sig_id_max);
    return err;
}
